#ifndef RP2CONTROLLER_H
#define RP2CONTROLLER_H

#include "Rp2Object.h"

namespace Rp2
{
class Controller : public Object
{
	RP2_DECLARE_RTTI;
	RP2_DECLARE_NAME_ID;

public:
	// destruction (abstract base class)
	virtual ~Controller();

	// the controlled object
	Object* GetObject() const;

	// animation update
	virtual bool Update(double dAppTime);

    enum RepeatType
    {
        RT_CLAMP,
        RT_WRAP,
        RT_CYCLE,
        RT_QUANTITY
    };

    RepeatType Repeat;  // default = RT_CLAMP
    double MinTime;     // default = 0.0
    double MaxTime;     // default = 0.0
    double Phase;       // default = 0.0
    double Frequency;   // default = 1.0
    bool Active;        // default = true

protected:
	// construction (abstract base class)
	Controller();

	// the controlled object
	friend class Object;
	virtual void SetObject(Object* Object);

    // Conversion from application time units to controller time units.
    // Derived classes may use this in their update routines.
    double GetControlTime (double dAppTime);

    // Regular pointer used for controlled object to avoid circular smart
    // pointers between controller and object.
    Object* m_pkObject;

    double m_dLastAppTime;

private:
	static const char* ms_aacRepeatType[RT_QUANTITY];

};

typedef Pointer<Controller> ControllerPtr;
#include "Rp2Controller.inl"

}

#endif